/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;


import javax.ejb.EJB;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import persistence.PharmaciesFacade;
import persistence.entity.Pharmacies;

/**
 *
 * @author ali
 */
@Named(value = "beanPharmacies")
@RequestScoped
public class BeanPharmacies{

    
    private Pharmacies pharmacies;

    @EJB
    private PharmaciesFacade facade;
    
    public BeanPharmacies() {
        this.pharmacies = new Pharmacies();
    }
    
    
    public String add()
    {
        this.facade.create(this.pharmacies);
        return "";
    }
    
    public int count()
    {
        return this.facade.count();
    }

    public Pharmacies getPharmacies() {
        return pharmacies;
    }

    public void setPharmacies(Pharmacies pharmacies) {
        this.pharmacies = pharmacies;
    }
    
    public void preRenderView() {  
      HttpSession session = ( HttpSession ) FacesContext.getCurrentInstance().getExternalContext().getSession( true );  
      //tune session params, eg. session.setMaxInactiveInterval(..);  
  
      //perform other pre-render stuff, like setting user context...  
   } 
    
    

}
